package com.zcr.producer;

import com.alibaba.fastjson.JSON;
import com.zcr.entity.User;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author ZhangCuirong
 * @Date 2024/9/24 16:38
 * @description: 生产者
 */
@RestController
@RequestMapping("/producer")
public class Producer {
    @Autowired
    RocketMQTemplate rocketMQTemplate;
    @GetMapping("/send")
    public void send(){
        User user=User.builder().name("zcr").age(18).build();
        rocketMQTemplate.syncSend("test", JSON.toJSONString(user));
    }

}
